﻿@model Sealight.Core.DataAdapter.product_variant
@{    
    string productName = string.Empty, productId=string.Empty, productVariantId = string.Empty, shortDescription = string.Empty, description = string.Empty,
       comment = string.Empty, image = string.Empty, imageUrl = "/ImageHandler.axd?imageSource=~/Content/images/no-photo-click.png&width=100&height=111";
    string pictureId = string.Empty;
    bool disableBuyButton = false;
    string productSKU = string.Empty, avaiableStartDate = string.Empty, avaiableEndDate = string.Empty, tax_cat_id = string.Empty;
    decimal weight = 0, height = 0, length = 0, width = 0, price = 0, oldPrice = 0, productCost = 0;
    int miniCartQuantity = 1, maxCartQuantity = 1000;

    if(Model != null)
    {
        productId = Model.product_id.ToString();
        productVariantId = Model.id.ToString();
        productName = Model.name;
        description = Model.description;
        productSKU = Model.SKU;
        avaiableStartDate = Model.available_start_date_time.HasValue ? Model.available_start_date_time.Value.ToString("dd/MM/yyyy") : string.Empty;
        avaiableEndDate = Model.available_end_date_time.HasValue ? Model.available_end_date_time.Value.ToString("dd/MM/yyyy") : string.Empty;

        price = Model.price;
        oldPrice = Model.old_price;
        productCost = Model.product_cost;

        weight = Model.weight;
        height = Model.height;
        length = Model.length;
        width = Model.width;
        miniCartQuantity = Model.order_minimum_quantity;
        maxCartQuantity = Model.order_maximum_quantity;

        if( Model.picture != null)
        {
            pictureId = Model.picture.id.ToString();
            image = Model.picture.picture_url;
            imageUrl = string.Format("/ImageHandler.axd?imageSource=~/Content/images/pictures/{0}&width=100&height=111", Model.picture.picture_url);
        }
        disableBuyButton = Model.disable_buy_button;
    }
    else
    {        
        productId = ViewData["productId"].ToString();   
    }

    IList<Sealight.Core.DataAdapter.product_category> categories = Sealight.UI.WebUI.Services.ProductService.GetAllProductCategory();
}
<input type="hidden" id="product_variant_id" value="@productVariantId"/>
<input type="hidden" id="product_id" value="@productId"/>
<table class="adminContent">
    <tbody>
        <tr>
            <td class="adminTitle">
                <span id="" title="The name of the product.">Tên sản phẩm biến thể:</span>
            </td>
            <td class="adminData">
                <input name="product_name_field" type="text" id="product_name_field" class="adminInput"
                    value="@productName" />
            </td>
        </tr>
         <tr >
            <td class="adminTitle">              
                <span id="" title="Product stock keeping unit (SKU). Your internal unique identifier that can be used to track this product.">
                    SKU sản phẩm:</span>
            </td>
            <td class="adminData">
                <input name="product_sku_field" type="text" id="product_sku_field" class="adminInput" value="@productSKU"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span title="The category image.">Chọn hình:</span>
            </td>
            <td class="adminData">
                <img src="@imageUrl" id="picture_field_image" title="Picture" alt="Picture"/>
                <br />
                <input type="hidden" name="hidden_image_name" id="hidden_image_name" value = "@image"/>
                <input type="hidden" name="hidden_image_id" id="hidden_image_id" value = "@pictureId"/>
                <input type="file" name="file_field" id="file_field" title="Choose a new category image to upload."
                    class="adminInput" />
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="A full description of the product.">Mô tả đầy đủ:</span>
            </td>
            <td class="adminData">
                <textarea id="description_field" name="description_field" style="width: 340px" rows="20"
                    class="Internal">@description</textarea>
            </td>
        </tr>

          <tr class="adminSeparator">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
       
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="The manufacturer's part number for this product.">Manufacturer part
                    number:</span>
            </td>
            <td class="adminData">
                <input name="manufacturer_part_number_field" type="text" id="manufacturer_part_number_field" class="adminInput"/>
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The price of the product.">Giá:</span> [VND]:
            </td>
            <td class="adminData">
                <input name="price_field" type="text" id="price_field" class="adminInput" value="@price"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The old price of the product. If you set an old price, this will display alongside the current price on the product page to show the difference in price.">
                    Giá cũ</span> [VND]:
            </td>
            <td class="adminData">
                <input name="old_price_field" type="text" id="old_price_field" class="adminInput" value="@oldPrice"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The product cost is the cost of all the different components which make up the product. This may either be the purchase price if the components are bought from outside suppliers, or the combined cost of materials and manufacturing processes if the component is made in-house.">
                    Chi phí sản phẩm:</span> [VND]:
            </td>
            <td class="adminData">
                <input name="product_cost_field" type="text" value="@productCost" id="product_cost_field" class="adminInput"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Check to disable the buy button for this product. This may be necessary for products that are 'available upon request'">
                    Tắt nút mua:</span>
            </td>
            <td class="adminData">
            @if (disableBuyButton)
            {
                <input id="disable_buy_button_field" type="checkbox" name="disable_buy_button_field" checked="checked"/>
            }
            else
            {
            <input id="disable_buy_button_field" type="checkbox" name="disable_buy_button_field"/>
            }
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The start of the product availability in Coordinated Universal Time (UTC).">
                    Ngày có thể bắt đầu:</span>
            </td>
            <td class="adminData">
                <input name="available_start_date_field" type="text" id="available_start_date_field" value="@avaiableStartDate"/><br/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="The end of the product availability in Coordinated Universal Time (UTC).">
                    Ngày kết thúc:</span>
            </td>
            <td class="adminData">
                <input name="available_end_date_field" type="text" id="available_end_date_field" value="@avaiableEndDate"/><br/>
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="Check if it is a gift card.">Is Gift Card:</span>
            </td>
            <td class="adminData">
                <input id="is_gift_card_field" type="checkbox" name="is_gift_card_field"/>
            </td>
        </tr>
        <tr class="adminSeparator" style="display:none;">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
       
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="Determines whether the product can be shipped.">Shipping enabled:</span>
            </td>
            <td class="adminData">
                <input id="shipping_enabled_field" type="checkbox" name="shipping_enabled_field" checked="checked" onclick="toggleShipping();"/>
            </td>
        </tr>
        <tr id="pnlFreeShipping" style="display:none;">
            <td class="adminTitle">
                <span id="" title="Check if this product comes with FREE shipping.">Free shipping:</span>
            </td>
            <td class="adminData">
                <input id="free_shipping_field" type="checkbox" name="free_shipping_field"/>
            </td>
        </tr>
        <tr id="pnlAdditionalShippingCharge" style="display:none;">
            <td class="adminTitle">
                <span id="" title="The additional shipping charge.">Additional shipping charge:</span>
                [VND]:
            </td>
            <td class="adminData">
                <input name="additional_shipping_charge_field" type="text" value="0" id="additional_shipping_charge_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlWeight">
            <td class="adminTitle">
                <span id="" title="The weight of the product. Can be used in shipping calculations.">
                    Trọng lượng:</span> [kg(s)]:
            </td>
            <td class="adminData">
                <input name="weight_field" type="text" id="weight_field" class="adminInput" value="@weight"/>
            </td>
        </tr>
        <tr id="pnlLength">
            <td class="adminTitle">
                <span id="" title="The length of the product.">Chiều dài:</span> [meter(s)]:
            </td>
            <td class="adminData">
                <input name="length_field" type="text" value="@length" id="length_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlWidth">
            <td class="adminTitle">
                <span id="" title="The width of the product.">Chiều rộng:</span> [meter(s)]:
            </td>
            <td class="adminData">
                <input name="width_field" type="text" value="@width" id="width_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlHeight">
            <td class="adminTitle">
                <span id="" title="The height of the product.">Chiều cao:</span> [meter(s)]:
            </td>
            <td class="adminData">
                <input name="height_field" type="text" value="@height" id="height_field" class="adminInput"/>
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="Determines whether this product is tax exempt (tax will not be applied to this product at checkout).">
                    Tax exempt:</span>
            </td>
            <td class="adminData">
                <input id="tax_exempt_field" type="checkbox" name="tax_exempt_field"/>
            </td>
        </tr>
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="The tax classification for this product. You can manage product tax classifications from Configuration : Tax : Tax Classes">
                    Tax category:</span>
            </td>
            <td class="adminData">
                <select name="tax_category_field" id="tax_category_field" class="adminInput">
                    <option value="0">---</option>
                     @if (categories != null)
                     {
                         foreach (var cat in categories)
                         {
                             if (cat.id.ToString() == tax_cat_id)
                             {
                                        <option value="@cat.id" selected>@cat.name</option> 
                             }
                             else
                             {
                                <option value="@cat.id">@cat.name</option> 
                             }
                             if (cat.childrens != null)
                             {
                                 foreach (var child in cat.childrens)
                                 {
                                     if (child.id.ToString() == tax_cat_id)
                                     {
                                <option value="@child.id" selected>--@cat.name</option>  
                                     }
                                     else
                                     {
                                <option value="@child.id">--@cat.name</option>  
                                     }
                                 }
                             }
                         }
                     }
                </select>
            </td>
        </tr>
        <tr class="adminSeparator" style="display:none;">
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr style="display:none;">
            <td class="adminTitle">
                <span id="" title="Check to enable system stock management. When enabled, stock quantities are automatically adjusted when a customer makes a purchase. You can also set low stock activity actions and receive notifications.">
                    Manage Stock:</span>
            </td>
            <td class="adminData">
                <select name="manage_stock_field" id="manage_stock_field" onchange="toggleManageStock();">
                    <option value="0">Don't track inventory for this product</option>
                    <option selected="selected" value="1">Track inventory for this product</option>
                    <option value="2">Track inventory for this variant by product attributes</option>
                </select>
            </td>
        </tr>
        <tr id="pnlStockQuantity" style="display:none;">
            <td class="adminTitle">
                <span id="" title="The current stock quantity of this product.">Stock quantity:</span>
            </td>
            <td class="adminData">
                <input name="stock_quantity_field" type="text" value="10000" id="stock_quantity_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlDisplayStockAvailability" style="display:none;">
            <td class="adminTitle">
                <span id="" title="Check to display stock availability. When enabled, customers will see stock availability.">
                    Display Stock Availability:</span>
            </td>
            <td class="adminData">
                <input id="display_stock_availability_field" type="checkbox" name="display_stock_availability_field"/>
            </td>
        </tr>
        <tr id="pnlMinStockQuantity" style="display:none;">
            <td class="adminTitle">
                <span id="" title="If you have enabled 'Manage Stock' you can perform a number of different actions when the current stock quantity falls below your minimum stock quantity.">
                    Minimum stock quantity:</span>
            </td>
            <td class="adminData">
                <input name="minimum_stock_quantity_field" type="text" value="0" id="minimum_stock_quantity_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlLowStockActivity" style="display:none;">
            <td class="adminTitle">
                <span id="" title="Action to be taken when your current stock quantity falls below the 'Minimum stock quantity'.">
                    Low stock activity:</span>
            </td>
            <td class="adminData">
                <select name="" id="" class="adminInput">
                    <option value="0">Nothing</option>
                    <option value="1">Disable Buy Button</option>
                    <option value="2">Unpublish</option>
                </select>
            </td>
        </tr>
        <tr id="pnlNotifyForQuantityBelow" style="display:none;">
            <td class="adminTitle">
                <span id="" title="When the current stock quantity falls below this quantity, the storekeeper (admin) will receive a notification.">
                    Notify admin for quantity below:</span>
            </td>
            <td class="adminData">
                <input name="notify_admin_quantity_field" type="text" value="1" id="notify_admin_quantity_field" class="adminInput"/>
            </td>
        </tr>
        <tr id="pnlAllowOutOfStockOrders" style="display:none;">
            <td class="adminTitle">
                <span id="" title="A value indicating whether to allow orders when out of stock.">Allow
                    out of stock orders:</span>
            </td>
            <td class="adminData">
                <input id="allow_out_stock_order_field" type="checkbox" name="allow_out_stock_order_field"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle" >
                <span id="" title="Set the minimum quantity allowed in a customers shopping cart e.g. set to 3 to only allow customers to purchase 3 or more of this product.">
                    Số lượng giỏ hàng tối thiểu:</span>
            </td>
            <td class="adminData">
                <input name="minimum_cart_quantity_field" type="text" value="@miniCartQuantity" id="minimum_cart_quantity_field" class="adminInput"/>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <span id="" title="Set the maximum quantity allowed in a customers shopping cart e.g. set to 5 to only allow customers to purchase 5 of this product.">
                    Số lượng giỏ hàng tối đa:</span>
            </td>
            <td class="adminData">
                <input name="maximum_cart_quantity_field" type="text" value="@maxCartQuantity" id="maximum_cart_quantity_field" class="adminInput"/>
            </td>
        </tr>
    </tbody>
</table>
